package net.shopxx.service.impl;

import java.util.List;

import javax.annotation.Resource;

import net.shopxx.dao.IndexfloortabDao;
import net.shopxx.entity.Indexfloor;
import net.shopxx.entity.Indexfloortab;
import net.shopxx.service.IndexfloortabService;

import org.hibernate.Hibernate;
import org.springframework.stereotype.Service;
import org.springmodules.cache.annotations.Cacheable;

/**
 * Service实现类 - 首页楼层tab
 */

@Service
public class IndexfloortabServiceImpl extends BaseServiceImpl<Indexfloortab, String> implements IndexfloortabService {

	@Resource
	private IndexfloortabDao indexfloortabDao;
	
	@Resource
	public void setBaseDao(IndexfloortabDao indexfloortabDao) {
		super.setBaseDao(indexfloortabDao);
	}
	
	@Cacheable(modelId = "caching")
	public List<Indexfloortab> getEnabledIndexfloortabList() {
		List<Indexfloortab> enabledIndexfloortabList = indexfloortabDao.getEnabledIndexfloortabList();
		if (enabledIndexfloortabList != null) {
			for (Indexfloortab enabledIndexfloortab : enabledIndexfloortabList) {
				Hibernate.initialize(enabledIndexfloortab);
			}
		}
		return enabledIndexfloortabList;
	}
	
	@Cacheable(modelId = "caching")
	public List<Indexfloortab> getEnabledIndexfloortabList(Indexfloor indexfloor) {
	    List<Indexfloortab> enabledIndexfloortabList = indexfloortabDao.getEnabledIndexfloortabList(indexfloor);
	    if (enabledIndexfloortabList != null) {
            for (Indexfloortab enabledIndexfloortab : enabledIndexfloortabList) {
                Hibernate.initialize(enabledIndexfloortab);
            }
        }
        return enabledIndexfloortabList;
	}
	
	

}